<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>多边形</title>
    <style type="text/css">
        *{
            margin: 0;
            padding: 0;
        }
        canvas{
            border: 1px solid red;
            margin: 0px 300px;
        }
    </style>
</head>
<body>
<canvas width="600" height="600" id="can">您的浏览器不支持画布</canvas>
<script type="text/javascript">
    var can=document.getElementById("can");
    //用画笔来作画
    var pen=can.getContext("2d");
    pen.beginPath();
    pen.moveTo(200,120);
    pen.lineTo(400,120);
    pen.lineTo(500,300);
    pen.lineTo(400,500);
    pen.lineTo(200,500);
    pen.lineTo(100,300);
    pen.strokeStyle="green";
    pen.lineWidth="2";
    pen.fillStyle="white";
    pen.fill();
    pen.closePath();
    pen.stroke();
</script>
</body>
</html>